<?php
$start_time=microtime(true);
$last_time=$start_time;
echo "<p>当前时间:$start_time</p>\r\n";
function print_time_interval()
{
    global $start_time,$last_time;
    $now_time=microtime(true);
    $last_interval=round($now_time-$last_time,4);
    $start_interval=round($now_time-$start_time,4);
    echo "<p>当前时间:$now_time,时间间隔:$last_interval,总计:$start_interval</p>\r\n";
    $last_time=$now_time;
}

$start_memory=memory_get_usage();
$last_memory=$start_memory;
echo "<p>内存占用:$start_memory</p>\r\n";
function print_memory_occupy()
{
    global $start_memory,$last_memory;
    $now_memory=memory_get_usage();
    $last_increase=$now_memory-$last_memory;
    $start_increase=$now_memory-$start_memory;
    echo "<p>内存占用:$now_memory,增加量:$last_increase,总计增加量:$start_increase</p>\r\n";
    $last_memory=$now_memory;
}

function print_performance($title="")
{
    echo "<br>\r\n";
    if($title){
        echo "<p>标题:$title</p>\r\n";
    }
    print_time_interval();
    print_memory_occupy();
}
